package com.bms.modules.oss.cloud;


import org.springframework.web.multipart.MultipartFile;

import io.minio.MinioClient;

public class OSSUtils {
	public static String upload(MultipartFile file, String path) {
		return minioUpload(file, path);
	}
	
	private static String minioUpload(MultipartFile file, String path) {
		String url= "";
		try {
	      // Create a minioClient with the Minio Server name, Port, Access key and Secret key.
	      MinioClient minioClient = new MinioClient("http://106.13.59.54:9000", "RH0IPZU7L1VQOF6CVA0W", "rgCBROM7gbOVj+blk74YY2nH6uTd9tsF++OBPy8B");
	      // Upload the zip file to the bucket with putObject
	      minioClient.putObject("bucket1",path,file.getInputStream(),file.getSize(),file.getContentType());
	      url = minioClient.getObjectUrl("bucket1", path);
	    } catch(Exception e) {
	    	e.printStackTrace();
	    }
		return url;
	}
}
